import {request} from '@umijs/max';
import {post} from "@/services/base-request";

/** 获取当前的用户 GET /api/currentUser */
export async function downloadFile(fileId: string | number, options?: { [key: string]: any }) {
  return request<any>(`/api/file/download/${fileId}`, {
    method: 'GET',
    ...(options || {}),
  });
}

export function downloadFileUrl(fileId: string | number) {
  return `/api/file/download/${fileId}`
}

export function fullDownloadFileUrl(fileId: string | number) {
  console.log(fileId)
  console.log(`http://127.0.0.1:8089/api/file/download/${fileId}`)
  return `http://127.0.0.1:8099/api/file/download/${fileId}`
}

export function uploadFile(file: File, options?: { [key: string]: any }) {
  return post('/file/upload', {file}, {}, {
    ...(options || {}),
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  })
}
